<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="zh-CN"><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css">
<title>UNLISTEN</title>
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head><body class="REFENTRY">
<div>
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><th colspan="5" align="center" valign="bottom">PostgreSQL 8.2.3 中文文档</th></tr>
<tr><td width="10%" align="left" valign="top"><a href="sql-truncate.html" accesskey="P">后退</a></td><td width="10%" align="left" valign="top"><a href="sql-truncate.html">快退</a></td><td width="60%" align="center" valign="bottom"></td><td width="10%" align="right" valign="top"><a href="sql-update.html">快进</a></td><td width="10%" align="right" valign="top"><a href="sql-update.html" accesskey="N">前进</a></td></tr>
</table>
<hr align="LEFT" width="100%"></div>
<h1><a name="SQL-UNLISTEN"></a>UNLISTEN</h1>
<div class="REFNAMEDIV"><a name="AEN54923"></a><h2>名称</h2>UNLISTEN&nbsp;--&nbsp;停止监听通知信息</div>
<a name="AEN54926"></a>
<div class="REFSYNOPSISDIV"><a name="AEN54928"></a><h2>语法</h2>
<pre class="SYNOPSIS">UNLISTEN { <tt class="REPLACEABLE"><i>name</i></tt> | * }</pre>
</div>
<div class="REFSECT1"><a name="AEN54931"></a><h2>描述</h2>
<p><tt class="COMMAND">UNLISTEN</tt> 用于删除一个现有的已注册 <tt class="COMMAND">NOTIFY</tt> 事件。<tt class="COMMAND">UNLISTEN</tt> 取消当前 PostgreSQL 会话中所有对通知条件 <tt class="REPLACEABLE"><i>name</i></tt> 的监听。特殊的条件通配符 <tt class="LITERAL">*</tt> 取消对当前会话的所有通知条件的监听。</p>
<p><a href="sql-notify.html"><i>NOTIFY</i></a> 包含一些对 <tt class="COMMAND">LISTEN</tt> 和 <tt class="COMMAND">NOTIFY</tt> 的更广泛的讨论。</p>
</div>
<div class="REFSECT1"><a name="AEN54944"></a><h2>参数</h2>
<div class="VARIABLELIST">
<dl>
<dt><tt class="REPLACEABLE"><i>name</i></tt></dt>
<dd><p>通知条件名称(任意标识符)</p></dd>
<dt><tt class="LITERAL">*</tt></dt>
<dd><p>所有此后端当前正在监听的通知条件都将被清除</p></dd>
</dl>
</div>
</div>
<div class="REFSECT1"><a name="AEN54957"></a><h2>注意</h2>
<p>即使取消一个你没有监听的事件，后端也不会报错。</p>
<p>每个后端在退出时都会自动执行 <tt class="COMMAND">UNLISTEN *</tt> </p>
</div>
<div class="REFSECT1"><a name="AEN54962"></a><h2>例子</h2>
<p>注册一个：</p>
<pre class="PROGRAMLISTING">LISTEN virtual;
NOTIFY virtual;
Asynchronous notification "virtual" received from server process with PID 8448.</pre>
<p>一旦执行了 <tt class="COMMAND">UNLISTEN</tt> ，以后的 <tt class="COMMAND">NOTIFY</tt> 命令都将被忽略：</p>
<pre class="PROGRAMLISTING">UNLISTEN virtual;
NOTIFY virtual;
-- 收不到 NOTIFY 事件</pre>
</div>
<div class="REFSECT1"><a name="AEN54970"></a><h2>兼容性</h2>
<p>SQL 标准里没有 <tt class="COMMAND">UNLISTEN</tt> 命令。</p>
</div>
<div class="REFSECT1"><a name="AEN54974"></a><h2>又见</h2><a href="sql-listen.html"><i>LISTEN</i></a>, <a href="sql-notify.html"><i>NOTIFY</i></a></div>
<div>
<hr align="LEFT" width="100%">
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="33%" align="left" valign="top"><a href="sql-truncate.html" accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">首页</a></td><td width="33%" align="right" valign="top"><a href="sql-update.html" accesskey="N">前进</a></td></tr>
<tr><td width="33%" align="left" valign="top">TRUNCATE</td><td width="34%" align="center" valign="top"><a href="sql-commands.html" accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">UPDATE</td></tr>
</table>
</div>
</body></html>